from django.shortcuts import render
import pdb
from models import Course
from models import MyManager
def index(request):
    for x in Course.objects.all():
        print x.title

#Controller for the simple_html page. That page displays all the courses in html.
#The page also has some js:
# When when you click the "click me" text on the page(simeple_html), the js send a request to the controller in
# ajax.py. That controller send back a simple massage saying " hello" or something. the javascript in the "simple_html" page then runs and displays a alert message with the received greeting (from the controller in ajax.py)
def simple_html(request):
    pdb.set_trace()
    all_courses=Course.objects.all()
    return render(request,'example',{'all_courses':all_courses})
#tesT:
    #hypothesis: when overriding manager in a model, the original manager functionality is preserved - if you've inherited your custom manager from the django manager (note: i'm extending the django "generic" manager. That manager is not specific to any model)
    #result: yes. 
def manager_test(request):
    all_courses=Course.objects.all()
    custom_query_result=Course.objects.myquery()
    return render(request,'manager_test',{'all_courses':all_courses,'custom_query_result':custom_query_result})

def frame(request):
    return render(request,'frame',{})
